<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-07-30 20:02:30
 * @LastEditTime: 2020-02-28 11:25:38
 * @LastEditors: Please set LastEditors
 -->
<!doctype html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <title></title>
    <link rel="stylesheet" type="text/css" href="css/vant.css">
    <link rel="stylesheet" type="text/css" href="css/base.css" />
    <script type="text/javascript" src="script/jquery.js"></script>
    <script type="text/javascript" src="script/layer/mobile/layer.js"></script>
    <script type="text/javascript" src="script/vue.min.js"></script>
    <script type="text/javascript" src="script/vant.min.js"></script>
    <script type="text/javascript" src="script/fastclick.js"></script>
    <script type="text/javascript" src="script/base.js"></script>
    <style type="text/css">
        body {
            zoom: 0.9;
        }



        .right {
            background: #fff;
            padding: 20px 0;
            width: 45%;
        }

        .bg {
            width: 100%;
            height: 100%;
            background-image: url(image/bg-1.png), url(image/bg-2.png);
            background-repeat: no-repeat, no-repeat;
            background-position: top right, bottom left;
            background-size: 170px 138px, 150px 124px;
            padding: 30px 25px 0 25px;
        }

        .op {
            font-weight: 700;
            color: #f7f7fb;
            font-size: 60px;
            margin-left: -24px;
            letter-spacing: -2px;
        }

        .logo {
            margin-top: -70px;
            padding-bottom: 20px;
            color: #1cae5e;
            font-weight: 700;
            font-size: 18px;
        }

        .logo>* {
            vertical-align: middle;
        }

        .form>div {
            background: #f7f7fb;
            border-radius: 8px;
            margin-bottom: 25px;
        }

        .form .label {
            font-size: 14px;
            color: #69707f;
            padding: 8px 16px 0 16px;

        }

        .form .van-cell {
            background: transparent;
            padding: 7px 16px;
        }

        .login-btn {
            padding-top: 20px;
        }

        .checkbox {
            background: transparent !important;
        }

        .van-checkbox__icon {
            background: #efefef;
        }

        .van-checkbox__icon .van-icon {
            border: 1px solid #efefef;
        }
    </style>
</head>

<body>
    <div id="app" v-cloak>
        <div class="box flex-direction-r">
            <div class="flex-main left"><img style="width: 100%;height: 100%;" src="image/ri_an_bg.png" /></div>
            <div class="right">
                <div class="bg">
                    <div>
                        <div class="op">LOGIN</div>
                        <div class="logo"><img src="image/ri_an_logo_new.png"
                                style="width: 45px;margin-right: 15px;"><span>宁波日安阀门有限公司</span></div>
                        <div class="form">
                            <div>
                                <div class="label">账号</div>
                                <van-field v-model="formData.loginName" placeholder="请输入账号"></van-field>
                            </div>
                            <div>
                                <div class="label">密码</div>
                                <van-field v-model="formData.pwd" type="password" placeholder="请输入密码"></van-field>
                            </div>
                            <div class="checkbox">
                                <van-checkbox v-model="isRemb" shape="square" checked-color="#65ac5f" icon-size="18px">
                                    <span style="color:#aaa">记住密码</span>
                                </van-checkbox>
                            </div>
                        </div>
                        <div class="login-btn">
                            <van-button color="#1cae5e" round :disabled="ifConfirm" :loading="ifConfirm"
                                loading-text="登录中..." type="primary" block @click="loginAPP">登&nbsp;&nbsp;&nbsp;&nbsp;录
                            </van-button>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>

<script type="text/javascript">
    var vm;
    apiready = function () {

        var loginIndex = 0;

        function ping(ip) {

            api.ajax({
                url: 'https://' + ip + '/Frame/SqlData?cmdname=ConnectionTest',
                data: {
                    values: {}
                },
                timeout: 20,
                method: 'post',
                dataType: 'json'
            }, function (ret, err) {
                if (ret) {
                    window.localStorage.setItem('serverIP', ip);
                    // APP.serverIP = ip;
                    vm.checkLoginStatus();
                } else {

                }
            });
        }


        vm = new Vue({
            el: '#app',
            data: {
                showLoading: false,
                formData: {
                    loginName: '',
                    pwd: ''
                },
                isRemb: false,
                showSimpleSelect: false,
                ifConfirm: false
            },
            created: function () {
                var that = this;

                ping(APP.serverIP1);
                ping(APP.serverIP2);

                // if (APP.getUserInfo()) {
                //     that.formData.loginName = APP.getUserInfo().LoginName;
                //     if (APP.getUserInfo().isRemb) {
                //         api.openWin({
                //             name: '主页',
                //             url: 'html/menu.html',
                //             reload: true,
                //             slidBackEnabled: false
                //         })
                //     }
                // }
            },
            methods: {
                checkLoginStatus: function () {
                    var that = this;
                    if (loginIndex) {
                        that.loginAPP();
                    } else {
                        if (APP.getUserInfo()) {
                            that.formData.loginName = APP.getUserInfo().loginName;
                            if (APP.getUserInfo().isRemb && APP.getUserInfo().pwd) {
                                that.formData.pwd = APP.getUserInfo().pwd;
                                that.isRemb = true;
                                that.loginAPP();
                            }
                        }
                    }

                },
                loginAPP: function () {
                    var zyHmsScan = api.require('zyHmsScan');
                    var param = {
                        //returnAll:true
                    };
                    zyHmsScan.openDefaultView(param, function (ret) {
                        // alert(JSON.stringify(ret));
                    });

                }
            }
        })
    };
</script>

</html>